package com.lc.advertising.ui.activity;

import android.os.Bundle;
import android.widget.EditText;

import com.hjq.http.EasyHttp;
import com.hjq.http.listener.HttpCallback;
import com.lc.advertising.R;
import com.lc.advertising.app.AppActivity;
import com.lc.advertising.http.request.CzAddApi;
import com.lc.advertising.http.response.RegisterBean;
import com.lc.advertising.other.IntentKey;
import com.lc.advertising.util.CourseUtils;
import com.lc.advertising.util.SPUtil;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class RechargeActivity extends AppActivity {
    @BindView(R.id.et_money)
    EditText etMoney;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_recharge;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick(R.id.btn_recharge)
    public void onClick() {
        chongzhi();
    }

    private void chongzhi() {
        if (CourseUtils.isNullOrEmpty(etMoney.getText().toString().trim())){
            toast("请输入充值金额");
            return;
        }
        EasyHttp.post(this)
                .api(new CzAddApi()
                        .setUid(SPUtil.get(this, IntentKey.UID,"")).setPrice(etMoney.getText().toString().trim()))
                .request(new HttpCallback<RegisterBean>(this) {

                    @Override
                    public void onSucceed(RegisterBean data) {
                        toast(data.getMessage());
                        if (data.getCode() == 200) {
                            finish();
                        }

                    }


                });
    }
}
